package com.lp.yuojbackendquestionservice.controller.inner;

import com.lp.yuojbackendmodel.entity.Question;
import com.lp.yuojbackendmodel.entity.QuestionSubmit;
import com.lp.yuojbackendquestionservice.service.QuestionService;
import com.lp.yuojbackendquestionservice.service.QuestionSubmitService;
import com.lp.yuojbackendserviceclient.service.QuestionFeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/inner")
public class QuestionInnerController implements QuestionFeignClient {
    @Resource
    private QuestionService questionService;
    @Resource
    private QuestionSubmitService questionSubmitService;

    /**
     * 根据id查问题
     *
     * @param questionId
     * @return
     */
    @Override
    @GetMapping("/get/id")
    public Question getById(@RequestParam("questionId") long questionId) {
        return questionService.getById(questionId);
    }

    /**
     * 根据id查提交记录
     *
     * @param questionSubmitId
     * @return
     */
    @Override
    @GetMapping("/question_submit/get/id")
    public QuestionSubmit getSubmitById(@RequestParam("questionSubmitId") long questionSubmitId) {
        return questionSubmitService.getById(questionSubmitId);
    }


    /**
     * 根据id更新提交记录
     *
     * @param questionSubmitUpdate
     * @return
     */
    @Override
    @GetMapping("/question_submit/update")
    public boolean updateSubmitById(@RequestParam("questionSubmitUpdate") QuestionSubmit questionSubmitUpdate) {
        return questionSubmitService.updateById(questionSubmitUpdate);
    }
}
